{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [],
   "source": [
    "import requests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [],
   "source": [
    "#构造地址请求\n",
    "userName = 'maqiying'\n",
    "repoName = 'maqiying'\n",
    "url = f'https://gitee.com/api/v5/repos/{userName}/{repoName}/commits?page=1&per_page=20'\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [],
   "source": [
    "#发送请求\n",
    "import requests\n",
    "\n",
    "response = requests.get(url)\n",
    "#print(type(response.json()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 171,
   "metadata": {},
   "outputs": [],
   "source": [
    "date = response.json()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 172,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas\n",
    "df = pandas.DataFrame(date)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 173,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'author': {'name': 'maqiying',\n",
       "  'date': '2021-10-18T21:14:51+08:00',\n",
       "  'email': '9730847+maqiying@user.noreply.gitee.com'},\n",
       " 'committer': {'name': 'maqiying',\n",
       "  'date': '2021-10-18T21:14:51+08:00',\n",
       "  'email': '9730847+maqiying@user.noreply.gitee.com'},\n",
       " 'message': 'xxxxxx\\n',\n",
       " 'tree': {'sha': 'ce374f3ed7ac894cb3aa3cdf5b9c4cdf16f87996',\n",
       "  'url': 'https://gitee.com/api/v5/repos/maqiying/maqiying/git/trees/ce374f3ed7ac894cb3aa3cdf5b9c4cdf16f87996'}}"
      ]
     },
     "execution_count": 173,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[1,\"commit\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 174,
   "metadata": {},
   "outputs": [],
   "source": [
    "def getcommitDate(commit):\n",
    "    return commit['author']['date']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 175,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['commitDate'] = df['commit'].apply(getcommitDate)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 176,
   "metadata": {},
   "outputs": [],
   "source": [
    "datestr ='2021-11-08T23:08:13+08:00'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 177,
   "metadata": {},
   "outputs": [],
   "source": [
    "#将字符串转化为日期\n",
    "from datetime import datetime \n",
    "def getcounts(str):\n",
    "     d = datetime.fromisoformat(str)\n",
    "     return d.isocalendar()[1]-datetime(2021,8,30).isocalendar()[1]+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 178,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "10"
      ]
     },
     "execution_count": 178,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "getcounts('2021-11-01T23:08:13+08:00')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 179,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 计算机所有推送的周次\n",
    "df['counts'] =df['commitDate'].apply(getcounts)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 184,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 184,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df['counts'].value_counts())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 185,
   "metadata": {},
   "outputs": [],
   "source": [
    "x = df['counts'].value_counts().index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 186,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = df['counts'].value_counts().values"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 187,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 188,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<BarContainer object of 5 artists>"
      ]
     },
     "execution_count": 188,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/MnkTPAAAACXBIWXMAAAsTAAALEwEAmpwYAAARY0lEQVR4nO3dfZBdd13H8ffHtAV5GEjJgpiHpmpGKA9tcSeAMFIEQniwwZHRRB4KUyYzDAVER6fVmdYp/xRxBJVCyZRYUEjBQiVKoM1QsGptzRZq6QOFNRSysZiFQHkcasrXP/bUuWx3c2+yd3OXX96vmTt7zu/h3O+97Xzuybnn3JOqQpLUrp8ZdQGSpMVl0EtS4wx6SWqcQS9JjTPoJalxJ4y6gLmsWLGi1q5dO+oyJOmnxs033/yNqhqbq29JBv3atWuZmJgYdRmS9FMjyVfn6/PQjSQ1zqCXpMYZ9JLUOINekhpn0EtS4wx6SWpc36BPsjrJZ5LckeT2JG+eY0yS/FWSySS3JnlaT985Sb7cPc4Z9guQJB3eIOfRHwL+oKo+l+SRwM1JdlfVHT1jXgSs6x5PB94DPD3JycBFwDhQ3dydVfWtob4KSdK8+u7RV9U9VfW5bvm7wJ3AylnDNgEfqBk3Ao9O8njghcDuqjrYhftuYONQX4Ek6bCO6MrYJGuBM4GbZnWtBPb1rE91bfO1z7XtrcBWgDVr1hxJWT9h7fmfOOq5R+ruS15yzJ5rIY7lewI/Pe+LdLwY+MvYJI8APgr8XlV9Z9iFVNW2qhqvqvGxsTl/rkGSdBQGCvokJzIT8h+sqo/NMWQ/sLpnfVXXNl+7JOkYGeSsmwDvA+6sqr+YZ9hO4NXd2TfPAO6tqnuAa4ANSZYnWQ5s6NokScfIIMfonwW8CvhCklu6tj8G1gBU1WXALuDFwCTwA+C1Xd/BJG8F9nTzLq6qg0OrXpLUV9+gr6p/BdJnTAFvmKdvO7D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okpyY5iZkvV3fOGrMTOKdbfjlwXVVV1765OyvnVGAd8B/DKV2SNIi+h266Y+7nAdcAy4DtVXV7kouBiaraCbwP+Nskk8BBZj4M6MZ9BLgDOAS8oaruX6TX0orj/vDVHHxP5ub78mC+J3PIzI63JKlVXhkrSY0z6CWpcQb9EpNkWZLPJ/mnUdeyFCR5dJKrknwxyZ1JnjnqmkYtyVuS3J7ktiQ7kjx01DWNQpLtSQ4kua2n7eQku5N8ufu7fJQ1LhUG/dLzZuDOURexhPwl8KmqegJwOsf5e5NkJfAmYLyqnszMCRKbR1vVyFzBzE+r9Dof+HRVrQM+3a0f9wz6JSTJKuAlwOWjrmUpSPIo4NeYOauLqrqvqr490qKWhhOAn+2uWXkY8N8jrmckqup6Zs7y69X7cyzvB152LGtaqgz6peWdwB8BPx5xHUvFqcA08Dfd4azLkzx81EWNUlXtB/4c+BpwD3BvVV072qqWlMdV1T3d8teBx42ymKXCoF8ikrwUOFBVN4+6liXkBOBpwHuq6kzg+xzn/xTvjjlvYuZD8OeBhyd55WirWpq6izY9fxyDfil5FnB2kruZ+YXQX0/yd6MtaeSmgKmquqlbv4qZ4D+ePR/4SlVNV9X/Ah8DfnXENS0l/5Pk8QDd3wMjrmdJMOiXiKq6oKpWVdVaZr5cu66qjus9tar6OrAvyS93Tc9j5irr49nXgGckeVj3U+DP4zj/gnqW3p9jOQf4+AhrWTKWzK9XSvN4I/DB7neW9gKvHXE9I1VVNyW5CvgcMz8r8nmO08v+k+wAzgJWJJkCLgIuAT6S5Fzgq8Bvj67CpcOfQJCkxnnoRpIaZ9BLUuMMeklqnEEvSY0z6CWpcQa9JDXOoJekxv0fmdXnss3sy88AAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.bar(x,y)"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "3beccce4ce41e1547049ed455dd2b068221f54a61fc44b63e6db4e9dbf858918"
  },
  "kernelspec": {
   "display_name": "Python 3.8.5 64-bit",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
